<?php
include('includes/connection_settings.php');

if (!isset($_COOKIE['username'])) {
 echo("Log in first!");
 exit;
}

echo "<h1>Add words</h1>";

//Echos links to the dictionaries
$table = mysql_query("SELECT dictionary FROM words GROUP BY dictionary ORDER BY dictionary ASC");
if (!isset($table)) {
 echo "<h1>Can't choose data from the table!</h1><p>" . mysql_error($connection) . "</p>";
 exit;
}

if (mysql_result($table, 0, 0) != "") {
 echo "<p>Choose the wanted dictionary from the following list:</p>";

 for ($i = 0; $i < mysql_num_rows($table); $i++) {
  echo "<p class='likeLink'
   onClick='showAddWordsForm(\"exists\", \"" . mysql_result($table, $i, 0) . "\")'
   >" . mysql_result($table, $i, 0) . "</p>";
 }
}

echo "
<p>Give a new detailed dictionary:</p>
<input class='shortInput' type='text' id='language' maxlength='20' value='English' />
<input class='shortInput' type='text' id='bookSerie' maxlength='20' value='CultureCafe' />
<input class='shortInput' type='text' id='bookNumber' maxlength='20' value='Book5' />
<input class='shortInput' type='text' id='chapter' maxlength='20' value='Chapter7' />
<input onClick='showAddWordsForm(\"detailed\")' type='button' value='->' />";

echo "
<p>Give a new free-named dictionary:</p>
<input class='longInput' type='text' id='dictionary' maxlength='80' value='English' />
<input onClick='showAddWordsForm(\"freeNamed\")' type='button' value='->' />";

?>